/**
 * 角色模块路由文件
 */

const Router = require('koa-router');
const router = new Router();
const { validate } = require('../validators/common');
const { add, update, getAll, deleteRole, setRights } = require('../services/roles');
const { validAdd, validUpdate, validSetRights } = require('../validators/roles');
const { authorization } = require('./common');

router.prefix('/roles');

router.post('/add', authorization('rolesAdd'), validate(validAdd), add);

router.put('/update', authorization('rolesUpdate'), validate(validUpdate), update);

router.get('/all', authorization('rolesAll'), getAll);

router.delete('/delete/:id', authorization('usersDelete'), deleteRole);

router.put('/setRights', authorization('rightsSet'), validate(validSetRights), setRights);

module.exports = router;